package com.lz.demo5;

/**
 * @ClassName Student
 * @Description 学生类
 * @Author 2214361854
 * @Date 2022/5/28 14:52
 * @Version 1.0
 */
//1.定义学生类
public class Student {
    //2.定义学生类的属性
    private int sno;//学号
    private String name;//姓名
    private char gender;//性别
    private Major major;//专业
    private double totalScore;//总成绩

    //3.提供本类的全参构造,注意分数需要调用Major类的getScore()获取
    public Student(int sno, String name, char gender, Major major, double totalScore) {
        this.sno = sno;
        this.name = name;
        this.gender = gender;
        this.major = major;
        this.totalScore = major.getScore();
    }

    //4.重写toString()方法,方便直接查看学生类的所有属性值
    @Override
    public String toString() {
        return "学号:" + sno +
                ", 姓名:'" + name + '\'' +
                ", 性别:" + gender +
                ", 专业:" + major +
                ", 总成绩:" + totalScore;
    }

    public int getSno() {
        return sno;
    }

    public void setSno(int sno) {
        this.sno = sno;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public Major getMajor() {
        return major;
    }

    public void setMajor(Major major) {
        this.major = major;
    }

    public double getTotalScore() {
        return totalScore;
    }

    public void setTotalScore(double totalScore) {
        this.totalScore = totalScore;
    }
}
